package io.renren.common.utils;


public class ResultInfo {

    /**
     * 状态
     */
    private Boolean state;

    /**
     * 代码
     */
    private String code;

    /**
     * 消息
     */
    private String message;

    //数据
    private Object data;

    public ResultInfo() {

    }

    public ResultInfo(Boolean state, String code, String message, Object data) {
        this.state = state;
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ResultInfo(Boolean state, String message, Object data) {
        this.state = state;
        this.message = message;
        this.data = data;
    }

    //返回前端成功，不带数据和消息
    public static ResultInfo success() {
        return new ResultInfo(Boolean.TRUE, "", null);
    }

    //返回前端成功，不带数据
    public static ResultInfo success(String message) {
        return new ResultInfo(Boolean.TRUE, message, null);
    }

    //返回前端成功，带数据
    public static ResultInfo success(Object data) {
        return new ResultInfo(Boolean.TRUE, "", data);
    }

    //返回前端失败信息
    public static ResultInfo error(String message) {
        return new ResultInfo(Boolean.FALSE, message, null);
    }

    //返回APP异常信息
    public static ResultInfo error(String code, String message) {
        return new ResultInfo(Boolean.FALSE, code, message, null);
    }

    public Boolean getState() {
        return state;
    }

    public void setState(Boolean state) {
        this.state = state;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
